package webalbum.google;

import com.google.gdata.data.photos.AlbumFeed;
import com.google.gdata.data.photos.PhotoEntry;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import webalbum.WebAlbum;
import webalbum.WebAlbumPhoto;

/**
 *
 * @author zheismann
 */
public final class GoogleWebAlbum implements WebAlbum
{
    private AlbumFeed albumFeed;
    
    public GoogleWebAlbum(AlbumFeed af)
    {
        albumFeed = af;
    }
    
    public String getName()
    {
        return albumFeed.getName();
    }
    
    public String getId()
    {
        return albumFeed.getId();
    }
    
    public String getDescription()
    {
        return (albumFeed.getDescription() != null ? albumFeed.getDescription().getPlainText() : "");
    }
    public URI getURI()
    {
//        albumFeed.getId()
        return null;//albumFeed.get
    }
    public int getNumPhotos()
    {
        return albumFeed.getPhotoEntries().size();
    }
    
    public List<WebAlbumPhoto> getPhotos()
    {
        List<WebAlbumPhoto> photos = new ArrayList<WebAlbumPhoto>();
        for (PhotoEntry pe : albumFeed.getPhotoEntries())
        {
            photos.add(new GoogleWebAlbumPhoto(pe));
        }
        return photos;
    }
    public String toString()
    {
        StringBuilder sb = new StringBuilder();
        sb.append("name: "+getName()).append("\n\tid: "+getId()).append("\n\tURI: "+getURI())
                .append("\n\tNumPhotos: "+getNumPhotos());
        for (WebAlbumPhoto photo : getPhotos())
        {
            sb.append(photo);
        }
        
        return sb.toString();
    }    
}
